home *** CD-ROM | disk | FTP | other *** search
Wrap
Subject: RE>Re: Patching ODWindowState Sent: 3/12/96 3:09 PM Received: 3/12/96 2:21 PM From: Rob Cope, rob@eclipse.cpcn.com Reply-To: OpenDoc-Interest@CILabs.ORG To: OpenDoc Related Technologies Interest List, OpenDoc-Interest@CILabs Date: 3/12/96 Subject: RE>Re: Patching ODWindowState Time: 3:24 PM Troy, Thank you for your speedy reply. As you can imagine, that wasn't what I wanted to here, but it is better than hearing nothing. I am trying to implement menus that are available not only when my part is active, but also when parts embedded in my part are active. I think I have figured out a way to get it to work by only replacing the menu DispatchModule, however. >I was one of the first people to write a patch for OpenDoc here, and I >discovered these problems. Unfortunately, there was not time to do >anything about them. You might consider at least changing the recipe before the next release :) Thanks, Rob Cope Eclipse Services -------------------------------------- Date: 3/12/96 3:06 PM To: Rob Cope From: Troy Gaul I knew there would be a question about patching and this problem eventually... >Following the "Patching OpenDoc" recipe on DR4, I created a replacement >for the WindowState object. Here is a code snippet that shows how I >create it: > > ODWindowState *realWindowState = session->GetWindowState(ev); > > OLWindowState *newWindowState = new OLWindowState; > newWindowState->InitOLWindowState(ev, realWindowState); > > session->SetWindowState(ev, newWindowState); > >My OLWindowState object overrides every method defined in OpenDoc's >WinStat.idl. Currently, every method but somInit and somUninit just calls >the realWindowState object to do the work. This works fine until I close >my part, when I get a SOM error, kODErrInvalidFrame. Here is an excerpt >from the SOM trace at the point of the error. > .. > >Notice that two methods of ODWindowState, ODWindowStateAddIterator, and >ODWindowStateNext, are being called that were not overridden by my >subclass (I inserted the question marks). I did not override them because >they were not in the WinStat.idl file on the DR4 CD. Am I correct in >assuming that this is what is causing the problem? If so, is there an >updated idl file that I can get? If not, does anyone have any suggestions >about what is causing this problem? The problem is that not all of the functions that are defined in the WindowState (and probably other "patchable" objects as well) are in the public .idl/.xh file. You might notice that there are some "reserved" entries in the idl. These are actually used in the private version of the idl file for functions like the ones you mentioned. Also, beause of the way patching must work, it is necessary for the patching object to implement _all_ of the functions of the patched object and dispatch all of the calls on through to the original object. This means that in order to write a patch you'll need access to the private idl and xh files. I don't know if there is an approved mechanism to get those files from Apple or not. Also, note that if you write a patch, you have to be careful to make sure that the patch is only for the current version of the class that you are patching and that it will not be installed if there's a newer version of OpenDoc with a new version of that class. The reason this is important is that if we add a method to, say, ODWindowState in a new version, your patch won't know about that new method and cannot dispatch it to the original WindowState object, so things will break/crash. The upshot is that patching should be avoided as much as possible because it is a _very_ limited solution. If you depend on a patch and a user upgrades to a newer version of OpenDoc (with a change like this) the patch will stop working and so will your product. I was one of the first people to write a patch for OpenDoc here, and I discovered these problems. Unfortunately, there was not time to do anything about them. >By the way, I did this same thing replacing the ODDispatchModule that >handles menu events, and everything works fine. Dispatch modules are designed to be extensible in this way (that is, developers are expected to be able to implement their own or replacements), so there shouldn't be a problem with it. _troy ...................................................................... Troy Gaul tgaul@apple.com Apple Computer, Inc. OpenDoc Added Value Products ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::